home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MATH.SWG / 0067_Trig & hyperbolic functio.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-25  |  3KB  |  158 lines

  1. {
  2. MSGID: 2:228/406 68DEA672
  3. Here is the unit of trigonometric and hyperbolic
  4. real functions:
  5. }
  6.  
  7. UNIT trighyp;
  8. { Juhani Kaukoranta, Sysop of Pooki MBBS, Finland
  9.   Pooki MBBS 358-82-221 782 }
  10.  
  11. INTERFACE
  12.  
  13. FUNCTION TAN(x:Real):Real;
  14. FUNCTION COT(x:Real): Real;
  15. FUNCTION SEC(x:Real): Real;
  16. FUNCTION COSEC(x:Real): Real;
  17. FUNCTION SINH(x:Real): Real;
  18. FUNCTION COSH(x:Real): Real;
  19. FUNCTION TANH(x:Real): Real;
  20. FUNCTION COTH(x:Real): Real;
  21. FUNCTION SECH(x:Real): Real;
  22. FUNCTION COSECH(x:Real): Real;
  23. FUNCTION ARCSIN(x:Real):Real;
  24. FUNCTION ARCCOS(x:Real):Real;
  25. FUNCTION ARCCOT(x:Real): Real;
  26. FUNCTION ARCSEC(x:Real): Real;
  27. FUNCTION ARCCOSEC(x:Real): Real;
  28. FUNCTION ARCSINH(x:Real): Real;
  29. FUNCTION ARCCOSH(x:Real): Real;
  30. FUNCTION ARCTANH(x:Real): Real;
  31. FUNCTION ARCCOTH(x:Real): Real;
  32.  
  33. IMPLEMENTATION
  34.  
  35. FUNCTION TAN(x: Real): Real;
  36. { argument x is in radians }
  37. BEGIN
  38.    TAN := SIN(x)/COS(x);
  39. END;
  40.  
  41. FUNCTION COT(x:Real): Real;
  42. { cotangent, x is in radians }
  43. BEGIN
  44.    COT := 1/TAN(x);
  45. END;
  46.  
  47. FUNCTION SEC(x:Real): Real;
  48. { secant, x is in radians }
  49. BEGIN
  50.    SEC := 1/COS(x);
  51. END;
  52.  
  53. FUNCTION COSEC(x:Real): Real;
  54. { cosecant, x is in radians }
  55. BEGIN
  56.    COSEC := 1/SIN(x);
  57. END;
  58.  
  59. FUNCTION SINH(x:real):Real;
  60. { hyperbolic sin }
  61. BEGIN
  62.    SINH := (EXP(x)-EXP(-x))/2;
  63. END;
  64.  
  65. FUNCTION COSH(x:Real): Real;
  66. { hyperbolic cos }
  67. BEGIN
  68.    COSH := (EXP(x)+EXP(-x))/2;
  69. END;
  70.  
  71. FUNCTION TANH(x:Real): REAL;
  72. { hyperbolic tan }
  73. BEGIN
  74.    TANH := SINH(x)/COSH(x);
  75. END;
  76.  
  77. FUNCTION COTH(x: Real): Real;
  78. { hyperbolic cotangent }
  79. BEGIN
  80.    COTH :=SINH(x)/COSH(x);
  81. END;
  82.  
  83. FUNCTION SECH(x:Real): Real;
  84. { hyperbolic secant }
  85. BEGIN
  86.    SECH := 1/COSH(x);
  87. END;
  88.  
  89. FUNCTION COSECH(x:Real): Real;
  90. { hyperbolic cosecant }
  91. BEGIN
  92.    COSECH := 1/SINH(x);
  93. END;
  94.  
  95. FUNCTION ARCSIN(x:Real):Real;
  96. { inverse of sin, return value is in radians }
  97. BEGIN
  98.    IF ABS(x)=1.0  THEN
  99.       ARCSIN := x*Pi/2
  100.    ELSE
  101.       ARCSIN := ARCTAN(x/SQRT(-SQR(x)+1));
  102. END;
  103.  
  104. FUNCTION ARCCOS(x:Real):Real;
  105. { inverse of cos, return value is in radians }
  106. BEGIN
  107.    IF x = 1.0 THEN
  108.       ARCCOS := 0
  109.    ELSE IF x = -1.0 THEN
  110.       ARCCOS :=Pi
  111.    ELSE
  112.       ARCCOS := -ARCTAN(x/SQRT(-SQR(x)+1))+Pi/2;
  113. END;
  114.  
  115. FUNCTION ARCCOT(x:Real): Real;
  116. { inverse of cot, return value is in radians }
  117. BEGIN
  118.    ARCCOT := ARCTAN(1/x);
  119. END;
  120.  
  121. FUNCTION ARCSEC(x:Real): Real;
  122. { inverse of secant, return value is in radians }
  123. BEGIN
  124.    ARCSEC := ARCCOS(1/x);
  125. END;
  126.  
  127. FUNCTION ARCCOSEC(x:Real): Real;
  128. { inverse of cosecant, return value is in radians }
  129. BEGIN
  130.    ARCCOSEC := ARCSIN(1/x);
  131. END;
  132.  
  133. FUNCTION ARCSINH(x:Real): Real;
  134. { inverse of hyperbolic sin }
  135. BEGIN
  136.    ARCSINH := LN(x + SQRT(x*x+1));
  137. END;
  138.  
  139. FUNCTION ARCCOSH(x:Real): Real;
  140. { inverse of hyperbolic cos}
  141. BEGIN
  142.    ARCCOSH := LN(x + SQRT(x*x-1));
  143. END;
  144.  
  145. FUNCTION ARCTANH(x:Real): Real;
  146. { inverse of hyperbolic tan }
  147. BEGIN
  148.    ARCTANH := LN((1+x)/(1-x))/2;
  149. END;
  150.  
  151. FUNCTION ARCCOTH(x:Real): REAL;
  152. { inverse of hyperbolic cotangent }
  153. BEGIN
  154.    ARCCOTH := LN((x+1)/(x-1))/2;
  155. END;
  156.  
  157. END. { of unit }
  158.